package support;

import java.util.ArrayList;

public class Stat<T> {
    private ArrayList<T> data;
    
    public int Count()
    {
        return data.size();
    }

    public Stat()
    {
        data = new ArrayList<T>();
    }
    public void Add(T val)
    {
        data.add( val);
    }
    public double GetAvr()
    {
        double avr = 0;

        for (int i = 0; i < data.size(); i++)
        {
            avr += Double.parseDouble(data.get(i).toString());
        }
        return avr / data.size();
    }
    public double GetMax()
    {
        double max = -99999.9;
        for (int i = 0; i < data.size(); i++)
        {
            if (max < Double.parseDouble(data.get(i).toString()))
            {
                max = Double.parseDouble(data.get(i).toString());
            }
        }
        return max;
    }
    public double GetMin()
    {
        double min = 9999999.9;
        for (int i = 0; i < data.size(); i++)
        {
            if (min > Double.parseDouble(data.get(i).toString()))
            {
                min = Double.parseDouble(data.get(i).toString());
            }
        }
        return min;
    }
    public double GetStdev()
    {
        double stdev = 0;
        double avr = GetAvr();

        for (int i = 0; i < data.size(); i++)
        {
            double temp = Double.parseDouble(data.get(i).toString()) - avr;
            stdev += temp * temp;
        }

        stdev = Math.sqrt(stdev / data.size());
        return stdev;
    }
}

